#####################################

function decryptMachine {
 $BLVs = Get-BitLockerVolume
 foreach ($BLV in $BLVs) {
     Disable-BitLocker -MountPoint $BLV.MountPoint
 }
}

#####################################

function Invoke-FileWaveVerify {
    Write-Verbose "Executing FileWave Client Verify..."
    
    $programFilesPath = if ([IntPtr]::Size -eq 8) {
        [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFilesX86)
    } else {
        [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles)
    }

    $FileWavePath = Join-Path -Path $programFilesPath -ChildPath 'FileWave\fwGUI.exe'
    
    if (Test-Path -Path $FileWavePath) {
        Write-Output "Executing FileWave Client Verify using path: $FileWavePath"
        Start-Process -FilePath $FileWavePath -ArgumentList '--verify', '--silent' -NoNewWindow -Wait
        Write-Output "FileWave Client Verify executed. Waiting for 120 seconds..."
        Start-Sleep -Seconds 120
        Write-Output "120-second wait completed."
    }
    else {
        Write-Warning "FileWave Client not found at $FileWavePath"
    }
}


decryptMachine
Invoke-FileWaveVerify
exit 0
